package com.ideabove.custom;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.MediaController;

public class MyMediaController extends MediaController{

	Context _context;
	private MyMediaController.MediaControllerToggleListener m_mediaControllerToggleListener = null;
	    

    public interface MediaControllerToggleListener{
    	public void onMediaControllerToggle(boolean isShowing);
    }
    
    
    public MyMediaController(Context context, boolean useFastForward)
    {
        super(context, useFastForward);
        _context = context;
    }
     
    public MyMediaController(Context context, AttributeSet attrs)
    {
        super(context, attrs);
        _context = context;
    }
     
    public MyMediaController(Context context)
    {
        super(context);
        _context = context;
    }
     
    @Override
    public void setAnchorView(View view)
    {
    	 super.setAnchorView(view);
        /**
         * 0 : 전체
         * 1 : 버튼
         * 2 : seek bar
         */
        LinearLayout layout = (LinearLayout) getChildAt(0);
        
//        Log.e("####", "###" + layout.getChildCount());
        LinearLayout button = null;
        try{
        	// 겔스3
        	button = (LinearLayout)layout.getChildAt(0);
        }catch(Exception e){
        	// 나머지
        	button = (LinearLayout)layout.getChildAt(1);
        }
        
//        LinearLayout seek = (LinearLayout)layout.getChildAt(2);
//        Log.e("####", "###" + button.getChildCount());
        button.setVisibility(View.GONE);
       
        
    }
    

    public MyMediaController setOnMediaControllerToggle(MyMediaController.MediaControllerToggleListener l){
    	m_mediaControllerToggleListener = l;
    	return this;
    }
    
    
    public void show(){
    	
    	if(m_mediaControllerToggleListener != null){
    		m_mediaControllerToggleListener.onMediaControllerToggle(true);
    	}
    	
    	super.show();
    }
    
    public void hide(){
    	
    	if(m_mediaControllerToggleListener != null){
    		m_mediaControllerToggleListener.onMediaControllerToggle(false);
    	}
    	
    	super.hide();
    }
    
    


	

}
